#include<stdio.h>
int main()
{
	int n = 0;
	int m = 0;
	int arr1[100] = { 0 };
	int arr2[100] = { 0 };
	int arr3[200] = { 0 };
	scanf("%d %d", &n, &m);
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr2[i]);
	}
	i = 0;
	int j = 0;
	int k = 0;
	while (i < n&&j < m)
	{
		if (arr1[i] < arr2[j])
		{
			printf("%d ", arr1[i++]);
		}
		else
		{
			printf("%d ", arr2[j++]); 
		}
	}
	if (i == 0)
	{
		for (; j < m; j++)
		{
			printf("%d ", arr2[j]); 
		}
	}
	else
	{
		for (; i < n; i++)
		{
			printf("%d ", arr1[i]); 
		}
	}
	for (i = 0; i < k; i++)
	{
		printf("%d ", arr2[i]);
	}
	return 0;
}

/*int main()
{
	int n = 0;
	int m = 0;
	int arr1[100] = { 0 };
	int arr2[100] = { 0 };
	int arr3[200] = { 0 };
	scanf("%d %d", &n, &m);
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr1[i]);
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr2[i]);
	}
	 i = 0;
	int j = 0;
	int k = 0;
	while (i < n&&j < m)
	{
		if (arr1[i] < arr2[j])
		{
			arr3[k++] = arr1[i++];
		}
		else
		{
			arr3[k++] = arr2[j++];
		}
	}
	if (i == 0)
	{
		for (; j < m; j++)
		{
			arr3[k++] = arr2[j];
		}
	}
	else
	{
		for (; i < n; i++)
		{
			arr3[k++] = arr1[i];
		}
	}
	for (i = 0; i < k; i++)
	{
		printf("%d ", arr2[i]);
	}
	return 0;
}*/


/*int main()
{
	int n = 0;
	scanf("%d", &n);
	int arr[1000] = { 0 };
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 0; i < n; i++)
	{
		int j = 0;
		for (j = i + 1; j < n; j++)
		{
			if (arr[i] == arr[j])
			{
				int k = 0;
				for (k = j; k < n - 1; k++)
				{
					arr[k] = arr[k + 1];
				}
				n--;
				j--;
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}*/



/*int main()
{
	int n = 0;
	int arr[50] = { 0 };
	int del = 0;
	scanf("%d", &n);
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	scanf("%d", &del);
	int j = 0;
	for (i = 0; i < n; i++)
	{
		if (arr[i] != del)
		{
			arr[j++] = arr[i];
		}
	}
	for (i = 0; i < j; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}*/



/*int main()
{
	int n = 0;
	int arr[50] = { 0 };
	scanf("%d", &n);
	int flag1 = 0;
	int flag2 = 0;
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
		if (i>0)
		{
			if (arr[i] > arr[i - 1])
			{
				flag1 = 1;
			}
			else
			{
				flag2 = 1;
			}
		}
	}
	if (flag1 + flag2 == 1)
	{
		printf("sorted\n");
	}
	else
	{
		printf("unsorted\n");
	}
	return 0;
}*/



/*int main()
{
	int n = 0;
	scanf("%d", &n);
	int i = 0;
	int score = 0;
	int max = 0;
	int min = 100;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &score);
		if (score>max)
			max = score;
		if (score < min)
			min = score;
	}
	printf("%d\n", max - min);
	return 0;
}*/


/*int main()
{
	int i = 0;
	int num = 0;
	int positive = 0;
	int negative = 0;

	for (i = 0; i < 10; i++)
	{
		scanf("%d", &num);
		if (num >= 0)
			positive++;
		else
			negative++;

	}
	printf("positive:%d\n", positive);
	printf("negative:%d\n", negative);
	return 0;
}*/



/*int main()
{
	int arr[10] = { 0 };
	int i = 0;

	for (i = 0; i < 10;i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 9; i >= 0; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}*/

/*int main()
{
	int n = 0;
	int m = 0;
	int num = 0;
	int sum = 0;
	scanf("%d %d", &n, &m);
	int i = 0;
	for (i = 0; i < n; i++)
	{
		int j = 0;
		for (j = 0; j < m; j++)
		{
			scanf("%d", &num);
			if (num>0)
				sum += num;
		}
	}
	printf("%d\n", sum);
	return 0;
}*/
